package com.zany.util.quartz;

import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.zany.system.vo.ParameterSingleVO;
import com.zany.util.date.DateFormater;
import com.zany.util.param.SysParamKey;
import com.zany.util.quartz.service.JobService;

public class CopyJob extends org.springframework.scheduling.quartz.QuartzJobBean {
	
	private static Log logger = LogFactory.getLog(CopyJob.class);
	private ParameterSingleVO parameterSingleVO = new ParameterSingleVO();
	private JobService jobService;

	public CopyJob() {
	}
	
	public void setSession(Map arg0) {
		// TODO Auto-generated method stub

	}

	public void setJobService(JobService jobService) {
		this.jobService = jobService;
	}

	@Override
	protected void executeInternal(JobExecutionContext arg0)throws JobExecutionException {
		if(logger.isInfoEnabled()){logger.info("CopyJob.executeInternal()");}
		Process p = null;  
		try {  
			parameterSingleVO.setParamCode(SysParamKey.DATA_COPY.getKey());
			String path = jobService.getParameterSingleDetail(parameterSingleVO).getParamVal();
			String fileName = "children" + DateFormater.getSystemCurrentDateSimple()+".dmp";
			String cmd = "cmd /c Exp  children/children@orcl file= "+ path + fileName + " owner = (children)";
			p = Runtime.getRuntime().exec(cmd);  
		} catch (Exception e) {  
			e.printStackTrace();  
		} 
	}
	
	public static void main(String[] args){
		Process p = null;  
		try {  
			p = Runtime.getRuntime().exec("cmd /c Exp  house/house@orcl file= e:/HOUSE/COPY/HOUSECOPY.dmp tables=(house_area_t)");  
		} catch (Exception e) {  
			e.printStackTrace();  
		} 
	}

}
